#include<iostream>
#include<fstream>
#include<queue>
using namespace std;
struct huff{
    float w;
    char ans;
    huff *l,*r;
};
struct huffnode{
    huff *p;
    bool operator<(huffnode x) const
    {
        return p->w>x.p->w;
    }
};
huff* build()
{
    huff *p=new huff;
    p->l=nullptr;
    p->r=nullptr;
    return p;
}
huff *combine(huff *a,huff *b)
{
    huff *p=build();
    p->w=a->w+b->w;
    p->l=a;p->r=b;
    return p;
}
void uncode(huff *root,string code)
{
    if(root->l==nullptr&&root->r==nullptr)
    {
        cout<<root->ans<<" code "<<code<<endl;
        return;
    }
    uncode(root->l,code+"0");
    uncode(root->r,code+"1");
}
void uncode(huff *root,huff *allroot)
{
    if(root->l==nullptr&&root->r==nullptr) 
    {
        cout<<root->ans;
        root=allroot;
    }
    char ch;ch=cin.get();
    if(ch=='0')
    uncode(root->l,allroot);
    else if(ch=='1')
    uncode(root->r,allroot);
    else return;
}
int main()
{
    int n=26;huffnode allp[n];
    float x;int cnt=0;
    priority_queue<huffnode> q;
    for(int i=0;i<n;i++)
    {
        allp[i].p=build();
        cin>>allp[i].p->w;
        allp[i].p->ans=i+'a';
        q.push(allp[i]);
        cin.get();
    }
    huffnode root;
    while(q.size()>=2)
    {
        huffnode tmp=q.top();q.pop();
        root.p=combine(tmp.p,q.top().p);q.pop();
        q.push(root);
    }
    cout<<"code end,please enter artical"<<endl;
    uncode(root.p,"");
    uncode(root.p,root.p);
    return 0;
}



// 0.1 0.2 0.25 0.31 0.33 0.1 0.2 0.3 0.2 0.3 0.5 0.4 0.6 0.7 0.8 0.1 0.32 0.33 0.43 0.23 0.12 0.21 0.12 0.14 0.15 0.16
// 0100101100010111011110